import React, { Component } from 'react'
import { Button } from 'antd-mobile'
import WuIcon from '../wuIcon'
import './style.scss'
import { string, func, node, oneOfType } from 'prop-types'

class SearchBtn extends Component {
  render() {
    const { title, icon, onClick } = this.props
    const showicon = typeof icon === 'string' ? icon + ' ' : ''
    return (
      <div className='search-btn'>
        <Button type='ghost' className='am-button-borderfix' icon={icon} onClick={onClick}>
          {showicon}
          {title}
        </Button>
      </div>
    )
  }
}
SearchBtn.propTypes = {
  title: string.isRequired,
  icon: oneOfType([node, string]),
  onClick: func
}

SearchBtn.defaultProps = {
  onClick: () => {},
  icon: <WuIcon type='icon-sousuo' />
}

export default SearchBtn
